Skip reserving memory for non-executable and BL3-0 images
authorJuan Castillo <[email protected]>
Mon, 19 Jan 2015 16:51:21 +0000 (16:51 +0000)
committerDan Handley <[email protected]>
Wed, 28 Jan 2015 18:24:31 +0000 (18:24 +0000)
This patch adds support to not reserve the memory where an image is
loaded if the image is:

  1. A non-executable image e.g. a certificate
  2. An executable image which is not meant to run on the
     application CPU (e.g. BL3-0)

Both types of images are characterized by a NULL entrypoint argument
to the load_image() function. It is used to distinguish them from
other type of images.

Important: Use this feature carefully. The caller is responsible for
providing a valid entrypoint while loading images which will execute
on the application CPU to prevent a potential overwrite of the
corresponding memory region.

Change-Id: Ied482280d9db714c529ec12c33a6c1d918d77a4e

common/bl_common.c

index 60f8b2f7dd1cc57e64573a3f914a7d2d099e6610..8c241ec4893832033ca038ed4f3c7c1e4a2385d5 100644 (file)
@@ -275,9 +275,16 @@ int load_image(meminfo_t *mem_layout,
         * Update the memory usage info.
         * This is done after the actual loading so that it is not updated when
         * the load is unsuccessful.
+        * If the caller does not provide an entry point, bypass the memory
+        * reservation.
         */
-       reserve_mem(&mem_layout->free_base, &mem_layout->free_size,
-                   image_base, image_size);
+       if (entry_point_info != NULL) {
+               reserve_mem(&mem_layout->free_base, &mem_layout->free_size,
+                               image_base, image_size);
+       } else {
+               INFO("Skip reserving memory: 0x%lx - 0x%lx\n",
+                               image_base, image_base + image_size);
+       }
 
        image_data->image_base = image_base;
        image_data->image_size = image_size;